01: % +------------------------------+ 02: % | test for Prolog source | 03: % |______________________________| 04: 05: isinteger(X, L) :- type(X, int, L). 06: 07: % booleans 08: type(true, bool, _). 09: type(false, bool, _). 10: 11: type( and(X,Y), bool, L) :- isboolean(X,L), isboolean(Y,L). 12: type( or(X,Y), bool, L) :- isboolean(X,L), isboolean(Y,L). 13: type( not(X), bool, L) :- isboolean(X,L). 14: 15: type( succ(X), int, L ) :- isinteger(X,L). 16: type( pred(X), int, L ) :- isinteger(X,L). 17: type( iszero(X), bool, L ) :- isinteger(X,L). 18: type( X < Y, bool, L ) :- isinteger(X,L), isinteger(Y,L). 19: 20: % is_member(X,L) check whether X is in the list 21: % by using unification with occur check 22: 23: is_member(_, []) :- fail. 24: is_member(X, [Y | _]) :- unify(X,Y). 25: is_member(X, [_ | List]) :- is_member(X, List).